# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 1.导入等待类
from selenium.webdriver.support.wait import WebDriverWait

# 获取浏览器驱动
driver = webdriver.Firefox()
driver.maximize_window()
# 1.隐式等待，针对于所有的元素
# driver.implicitly_wait(20)
# sleep(20)
# 打开测试的网址
url = 'file:///C:/Users/tedu/Desktop/NSD2407/html/registerA.html'
driver.get(url)

# username = driver.find_element(By.CSS_SELECTOR, '#user')
# username.send_keys('admin')

# 创建等待对象  timeout 超时  poll_frequency查找频率
wait = WebDriverWait(driver, timeout=20, poll_frequency=0.5)
# 2.显示等待，针对于特定的某一个元素
wait.until(lambda x: x.find_element(By.CSS_SELECTOR, '#user')).send_keys('admin')

# 停顿3秒，关闭浏览器
sleep(3)
driver.quit()